package com.Lyyf.Controller;

import com.Lyyf.Entity.Flower;
import com.Lyyf.Service.FlowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Flower")
public class FlowerController {
    @Autowired
    public FlowerService flowerService;
    @GetMapping
    public List<Flower> SelectFlowerAll() {
        return flowerService.SelectFlowerAll();
    }
    @GetMapping(params = "flowerName")
    public List<Flower> SelectFlowerByName(String flowerName) {
        return flowerService.SelectFlowerByName(flowerName);
    }
    @GetMapping("{flowerId}")
    public Flower SelectFlowerById(@PathVariable String flowerId) {
        return flowerService.SelectFlowerById(Integer.parseInt(flowerId));
    }
    @PutMapping
    public int UpdateFlower(@RequestBody Flower flower) {
        return flowerService.UpdateFlower(flower);
    }
    @DeleteMapping("{flowerId}")
    public int DeleteFlower(@PathVariable String flowerId) {
        return flowerService.DeleteFlower(Integer.parseInt(flowerId));
    }
    @PostMapping
    public int InsertFlower(@RequestBody Flower flower) {
        return flowerService.InsertFlower(flower);
    }
}
